attempt to fix nested record: now it should be fully functional, needs more test, but it works