A new version of exercise 9.45 by Queequeg