change error from state to ref