updated math and changed interface