updated code to calculate time differences.