use os.closerange instead of iterating manually