added comments and refinements