some changes; amortized analysis