added a mod function