Optimize code

- Rearrange distribution code
- Improve the sample