add result header, fix bug in insert code