Filled out the psuedo code.