fixed a bug in is-safe

revealed after testing