fixed bug not waiting for tasks to complete in executor