added comments, removed debug stmts