Feature/moved client code and implemented middleware