Refactored into client