writing function for routes