popover code more concise but no longer working as wanted