add sorting to pq and fix permission access from direct url