removed an unnecessary recursion and added a type check to the backwards solver