Added a check to memory tracking