compatibility fix + defensive coding