Use pad function and add option to define cval