Added the mod function