made upload handling safer