Modified time spent and added comments to each function