Replacing append with extend