refactored, added caceling of tasks, but not working