fixed 'to_str' method not found exception in 1.8.7

This work both 1.8.7 and 1.9.3.