moved err routing to own file, formatted a bunch of code