simplify parseStructure function a bit