Changed query to improve performance