fixed some bugs in parsing