simplified code by using glob instead of scandir