corrected the time function