Update with clean solution to problem #4