8.4 algorithm