Added a return if canUpload is set to false, so that the function will stop running.