fixed mathematic errors