P6.9 and P6.10
by Caleb (untested code)