Updated popup function