restructured to use routes. needs some cleanup.