apply code to both routes