popupview logic