first working version of refactored invocation handler