added a little optimization in the klass query
added unauthorized user rerouting