cleanup code on problem 4