The step count is an important information for developing services for smartphone users. Most existing step counting solutions restrict that: the phone has to be fixed to the user and the user cannot use the phone naturally while walking. We can see that these restrictions are inconvenient for users. In this paper, we propose a step calculation algorithm, which can relieve the above restrictions and can count users' steps precisely. The proposed algorithm is composed of two phases. The first phase collects linear acceleration and gravity values from the smartphone's accelerometer. Then, this phase derives the horizontal components of the perceived linear acceleration values and identifies possible start points of periodical regular fluctuations (of linear acceleration measurements). The second phase adopts the concept of correlation coefficients to identify whether the collected sensing measurements exhibit similar tendencies and calculates step counts. In this paper, we implement the proposed method on the android platform. The experiment results indicate that the proposed scheme can analyze gaits accurately and count steps effectively.