Enhanced the query to run faster