popup: rethinking and refactoring (close #226)