completed RSA assignment - tweaking follows