Refactoring of Task manager