make ruby trinary more robust