add a couple of lines of checking code