Version of working code... still have some doubts about accuracy of kernel generation but RMSE calculation is fixed