fixing garbage collector containing no elements bug