algo: almost works