removed comments and patched parameter name and potential undefined error