refine code for routes and views