fixed 2 bugs in error functions