code of algorithm