Refactored to client server model