Need to work out swap function.