use basestring instead of str in flattenltlformula