rewrite checking functions