Another error fix

I'm a bit sleepy. In the previous commit I added a portion of code in the wrong place.