implement download and fixing some errors