allocation of unique items almost there. got a crashing problem with an array with 0 items