fix writing code