major refactor of code
api routes are working - still need to test