Better implementation for timediff