improved popup functionality