mod function add to cal.cpp