Added pseudo-code