refTyp substring fix

The substrin was not called on the proper string. Using the #/definitions as ref was not working in all the cases