workin flatten and normalize methods