refactor

* name and extract all sub functions
* put two lines before each functions