better rsa code structure