refactor code in ModalCTRL