add a check if block exists before writing