cleaned up upload and download functions