remove some duplication in todos_controller