refactoring server
refactored to use event emitter
merged development