fixed some math errors