refactor _real_to_rational