added the suggested checks. Not yet found the bug in heaps 3 and 4