added sequence validity checking