Updated the set function

It now properly checks whether virtuals exist at all, instead of assuming they do.