fixing logic that threw an undefined console error