refactoring modal functions