Added code to wait for results