refactor code, still throwing error for new todo item, review controller