Solution for #4.