Working solution (not checked).