factored out routes and db call; add knockout