lots of tweaking, still not fast enough...