improve readability of algorithm