better dispose logic