fixed fallback writing logic