Reorganized code for user editing and deleting