fixed a long-standing math error