updated loop condition, refactor displayAllTasks method