optimizing the performence of IO manipulation
fix some bugs