fixed error handling, added route handling