file uploading bug: fixed; refactored;