fixed
pseudocode for the rest of it