updating with more pseudocode