modify query to improve performance