Quick fix of algorithm