added high level psuedo code.