Why the remove method does not work?