TODO: solve it iteratively