Fix bound out of range panic.