fixed the linear algebra, which was horribly wrong