handle data received from server