improved unreachable states algorithm