improve download func