[crash fix]brings back the removed if statement in util.cpp and adds the num_level test to it like previous discontinued PR