add some comments, clean code