Fix #395 issue and fix read function