a working but very slow solver