Somewhat ugly way of dealing with invokeMethod