fix bug in weight function calculation: calculate ksq correctly