[SD] Refactor code.