added timeout update in write and fixed code style