Rewrite of check function.