refactored authentication into a module