fixed critical bug in kernel