Finished the 'extend' function.