update pseudo-code for writeup