better algo, but not good enough :p