Updated solution.