Measuring the Frequency of a TTL circuit

So I re-wrote the program again due to my class using the Arduino Mega and the Mstimer2 not working with it. So here is the new revision, which when outputting to the screen at 1/10th of a second, is fairly accurate, but when going above that, it quickly loses accuracy, any ideas why?

#include <SimpleTimer.h>
SimpleTimer timer;


int signalstate = 0;
int laststate = 0;
long int counter = 0;
long int screen = 0;
void repeatMe() 
{
  long int tempequ = ((counter / 5) * 6);
  screen = tempequ;
  Serial.println(screen, DEC);
  counter = 0;
}
 
void setup() 
{
  pinMode(9, INPUT);
  Serial.begin(9600);
  timer.setInterval(100, repeatMe);
}
//each time through the loop it does a read on the digital port,
//nothing happens till the pin goes "LOW" then each time through
// it checks to see if the state has changed, if so, then and
//only then does it increment the counter.
void loop() 
{
  timer.run();
  signalstate = digitalRead(9);
  if(signalstate == LOW)
  {
    laststate = 1;
  }
  if(laststate == 1 && signalstate == HIGH)
  {
    counter++;
    laststate = 0;
  }
  
}