some code cleaning and time calculation/display