Added alternative solution (props to Andrew Jones).