Simplified without memset
Further simplification of code
Filter out start and end tasks of the query
Print out first attempt at instances formula
Refactoring
Remove old print statements
Refactor formatting into separate method