Refactored Task class