moved download inside if to avoid problems on server