refactored file addition into its own function