modified gotoimmediate to use a thread