fixed bug in canWrite