Refactor manage_todos