Refactoring Task model to group similar code into only one function