add query limits and sorting