Added more advanced uploading algorithm