Extract popup generator to be more generic