reorganize, add some code comments and pseudo-code for utils