minor nit: maybe s/is_valid_target/ok/, for consistency with all other call sites. not sure though, up to you.