Simplified logic in `do_set`