Task 2 done properly, with chain initialisation and swapping implemented.