added one little error check

Nice, my first pull request ever :x)