enhanced the downloads.py algorithm