Fixed a bug in the remove method