fixing bug where error appeared more than once