Added time logic to controller