[BD] Refactor code.