Refactor switch statement under editTask