begin rewrite of check functions