Refactor handle registration result.
Refactor code.