more refactor on client