Scritp converted to function, support for download using proxy added