fixed an issue leading to  wrong error messages (unreachable code) at if statements