added error handling for syntax errors