refactoring. hooked up client and server side