Replace eval string with define_method block