Replaced convoluted loop with glob()