cleaned upload code