Refactored invoke method