refactored to one method for setting time