updated code with c library for download