still need to fix inverse, but rest looks ok