fixed bugs in parsing