code cleanup Problems 1 to 8