fix for limit queries with and without ordering