Updated to support non-nested format