refactor auth a bit