[SD] refactor code.