updated pad() function