refactor authentication register functionality