fixed IO routine for good