Refactor function invocation on object