started refactoring for client server model