speeding up extend()