problem 18 update, index bounds