vectorised check algorithm