separate authentication logic into a separate module