added comments
sanitized code