implemented automatic gc