fixed bug in computing time difference