changing insert queries for nested tables