implemented garbage collection