receive data algorithm