add write-on-empty and fix some bug