tweaked popover positioning logic