now handling sorts manually for performance