removed duplicate code from removeTask method