finalized (?) logic for bidi solver