refactored out the increment logic