computing time differences correctly