This document presents the fitness function x-means (ffx-means), a novel enhancement of the x-means clustering algorithm aimed at prolonging the lifetime of wireless sensor networks (WSNs) by effectively managing energy consumption. The ffx-means algorithm improves upon traditional x-means and k-means by implementing a method for determining the viability of cluster splitting based on specific network criteria and new techniques for selecting cluster-heads based on the remaining energy of nodes. Simulation results indicate that the ffx-means outperforms x-means by 11.5% and k-means by 75.34% in extending network lifetime while ensuring balanced energy consumption across nodes.