pep8 updates and formatting for 0 len lists when downloading
refactored function to make it smarter