completed problem 89
minor mods