put schema check in the right place