Made onInvoke 1-1 with old version
Wrapped code in IIFE