Fix bugs for showing error messages