code refactor, extract abstract client