first version of backwards solving