Parser: add a check so it doesn't crash on certain conditions