refactored file input for better flexibility