Updated timer code based on suggestions.