Fix remove logic and add an indexOf method