Refactored into authentication file