Fixed seg fault and added expr_check to loop and added error check for formal parameter type