fix mg_read bug: can recieve any length input