write own pseudo for problem 4a