Refactor ready for proper client