moved repeated code into a invokeObject method