Add logic for order by and limit.