object-ify popups to reduce code duplication