added more pseudocode