optimized code for fast donwloads