Corrected time function