fix error writecontext