fixed permissions
removed unused statements + added support for orderBy