complete refactor of authentication scheme