fix rational calculation