Refactor task class