improve step counter algorithm