better task execution, plus refactoring