function for determining time spent on task