refactored popup