Replaced some logics to the authentication library