refactors code to include a partial for the new and edit views