replace all IO with try statement