Refactor remove() method.
Fix a bug due to a variable name error.