Refactoring Edit Action Code to be more generalized to prepare for future features (putting code in its own function)