updated popup function and added exit button