Call ->has( 'orderby' ) in the if instead of above, and then do the get inside the if.