working copy, algorithm still FUCKED UP