refactored authentication checks