added paginate and some other fixes