a solution from discussion