Greater than but less than statement - PID sketch

 if(gap > .5 && < 1)   // this is incomplete

if(gap > .5 && gap < 1)      // this is probably what you wanted

if (.5 < gap && gap < 1)     // this is how I'd do it only because that shows gap between the two values

You've repeated this little error.