Add limit and offset functionality to query