refactoring mesh_io.cpp