copied luikores fix for the define_method call