catch errors & fix upload bug