added code for oredering and limit