added download logic