implement the kernel method

I've implemented the kernel method. feel free to change the code