Refactored popup to a template