here is the bug i+j is not unique should either be like benoit said or i*vec.size() + j