We consider the holes problem in wireless sensor netwoks by using the available energy fairly. The holes problem occurs when the available energy of some sensors are exhausted while others have significant energy. In this circumstance, ehile the total available energy of the network is high, the network is no longer working. Such a problem mainly happen due to unbalanced energy consumpsion in clustering and communication protocols. In this paper, we deal with this problem and propose an data aggregation algorithm based on the well-known clustering algorithm LEACH and tree construction mechanisms. In proposed method we consider the available energy of each sensor node as a weigthing parameter in clustering phase and tree-construction phase. Experimental results show the ability of the proposed method to increase the life time of the network and to distribute the energy uniformly along the network.