8 and 9 psuedo code