https://mingredbestcheapprice.blogspot.com/2022/07/converting-nested-for-loops-to.html