add some logic for client