refactor code to eliminate duplication on layout to use application.html.er