fixed remove: throws error when the length is equal or less then the index