Fixed small error check bug