Fixed math logic.