refactored authentication the ninja way