tighten up pseudocode to minimize database searches & add design notes