refine codes
add preview and download function to auto download