fixed some mathematical errors