improved rational function solving