added procedures to calculate spent time