Changing variable names to be more consistent with algorithm in book.