Replaced direct calls to define_method with send(:define_method)