CRITICAL BUG: fixed bug in GC algorithm