sequence checking function