Help with code that is not working correctly

Try leaving out the If(Serial.Available() > 0) and then maybe add a 5 millisecond delay. Not sure if you need the delay though, try it with the delay and without