using ruby procs instead of begin/rescue