Wireless sensor networks consist of hundreds or thousands of nodes with limited energy. Since the life time of each sensor is equivalent to the battery life, the energy issue is considered as a major challenge. Clustering has been proposed as a strategy to extend the lifetime of wireless sensor networks. Cluster size, number of Cluster head per cluster and the selection of cluster head are considered as important factors in clustering. In this research by studying LEACH algorithm and optimized algorithms of this protocol and by evaluating the strengths and weaknesses, a new algorithm based on hierarchical clustering to increase the lifetime of the sensor network is proposed. In this study, with a special mechanism the environment of network is layered and the optimal number of cluster head in each layer is selected and then recruit for the formation of clusters in the same layer by controlling the topology of the clusters is done independently. Then the data is sent through the by cluster heads through the multi