modified the popup logic to be executed when all requirements are met