Added event for closing the popUp with esc; Refactored the popUp