if (RI)
{
  RI = FALSE;
  if (RB8)
  {
    if (whatever you need to see to open this slave)
    (
      receive_data = TRUE
      return;
    }
  }
  else
  {
   if (receive_data)
    {
    process data till
    if (end_of_data
    {
       receive_data = FALSE