add some comments and clean up cfor