clean up some of the code and make them more clear to understand