algo improvement
n2