improved pseudocode