time function fix