another working version with const kernel