refactoring the code after we learnt that all the authenticate does is provide a factory method