optimalizes the query , much much faster now