Fixed bug when creating kernel