`is_string("$rsa")` looks rather weird. You're testing toString? I guess this will be empty string in doubt and this always true.