replacing begin/rescue statement