Refactor authentification