First psuedo code attempt