added server code, refactored some methods
works for localhost only?