For the remove command, add verification code that the index is in range.