put the logic into a separate function just to make it possible to switch easily.