generate __check() code