finished pseudocode and initial code