Fixed bug in kernel