added code for invoke()