Issue with reading serial data

Sure, I have posted the code below. I used the pulseIn() function just to find the start of the data, once I detected the rising edge of the data, with a small delay(in my case 1us), I start reading the data at equal intervals of time(thereby 8us for the case of 16us time period signal, shown in code below), in that way I got exact values which I wanted but due to other delays(like digitalRead, etc, there is still bit delay because of that sometimes I got wrong values, I explained it further below)

#define GPIO_PREFER_SPEED 1 //to increase speed further, doesn't work as of now so pls ignore
//#include "pins2_arduino.h" //Still working on it to decrease the total delay in digitalRead
#include "TimerOne.h"

unsigned int a[50];
int i;
int j;
//byte PWM_PIN = 3;
int pwm_value;

void setup() 
{
DDRD = DDRD | B00000000; //defining port D pins as input
pinMode(PD3, INPUT); //arduino pin 3 which is PD3 as input
Serial.begin(9600);
Timer1.initialize(16); //Timer1 period of 16us, break analogWrite() for digital pins 9&10 on Arduino 
Timer1.pwm(9, 512); //pin 9 as output, produces sqauare pulse of frequency 62.5kHz
}

void loop() 
{
  pwm_value = pulseIn(PD3, HIGH); //to detect the first rising edge of the data
  if (pwm_value>1) //once rising edge detected, we start storing the data
  {
    readfunction(); //fuction to store data, we can also write that code here itself
  }
  for(j=0;j<50;j++)
  {
    Serial.print(a[j]);  //printing the first 100 bits serial data that is stored in the buffer
  }
  Serial.println("\n End of data");
  while(1){}//to end the loop completely
}

void readfunction()
{
  for(i=0; i<50; i++) //reading and storing the first 100 bits
  {
    a[i]= digitalRead(PD3);//reading serial data from pin 3 of arduino every 8us
    delayMicroseconds(4); //approx 4us extra time to store the data in the background
    //so for a delay of 16us, define only 12us of delay
    //similarly, for delay of 8, define only 4us of delay
  } 
}

The code actually works up to some extent. When I try to check the output on the serial monitor I got this:
01010101010101010101011010101010101010101010101001
End of data
Which is actually close to the actual values which I wanted: 010101010101010101010101010101010101010, it's just sometimes I'm getting continuous 11 or 00 instead of 0101 as shown above, so I can't rely on this technique as I would need exact values.

Please let me know if we could do something about it, thanks in advance.