cal function.