Refactored controller for proper add/edit