corrected substractTime function