removed unused code
removed bug when there are 0 tasks