refactored file editing with jquery