move begin/rescue/end block into noecho method