refactor the code that save a todo (by extracting a function)