refactored access rules handling based on suggestions from weavejester