sequence model implementation