added comments; deleted some debug print