refactor controller for modals