use time_diff everywhere & put utility functions into single file