improved algorithm
clearer code