improved upload handling