fixing bug with error message showing too often