protect addToMap function from not having a record get created