This is not new functionality. I have only moved it into separate function to improve readability.