Refactor tasks structure