Added code for checking program for correct grammar