should the begin/end block here could be extracted to a method?