refactor taskmanager