BERT algorithm