little code clean and add a few comments