replaced os.walk and some other changes