adding more type checking

+ one more comment added
+ using the semantic FINAL "constant variable" for checking for the final state.