refactoring authentication function
change to new auth function
remove comments