fix bug in kernel function