refactored stepCount(), added javadocs and comments