Added swp functions from book.