added some robustness to the parser