second version of new step counter algorithm