using switch on io res(ult) instead of if else