Update route functionality and code refactor