polish pseudocode and write up readme