added processRoutes function to process the routes. incomplete