simplify popups code