added more syntax checking and error handling (line numbers)