Modified Solution 4