refactoring and added skeleton for networking