Changed the check to one that doesn't cause a valgrind error