coherent but suboptimal solution
some more changes, almost there!