much tighter solution to exercise 4