Fix for UnboundLocalError: local variable 'rating_text' referenced before assignment