adding NotAuthorized Exception to query construction