Small Optimization to Problem 4