Add waitForThread method before returning variables