Time function fix