Added download handler code (not tested)