refactored functions in todo.php