popup refactoring