improved function of timepicker