fixed a memory alloc bug
fixed the function read_inside()