refactor popup