fixing the type name method to account for element refs