trying to fix the allocElem bug