refactored modal ctrl