refactored and documented timer