pasted psuedocode
more psuedocode