How are royalties calculated?