Don't remove elements beyond the end of the array