ch5, ex 6 re-implemented