added more logic for timer