removing foreach from sort on new template