REfactoring of purchasedialog to be thread safe - not yet tested