refactored time method