Added file upload feature and refactored code