Add auth callback and refactoring