implementing some garbage collection