added notes
updated pseudo code