adding in code for problem29