Royston function now seems to work.  Needs more testing