fixed some bugs and added syntax error exception