make write synchronized, so that we do not get weird errors