Improved addRoute function