fix bug of schema not being written and read properly