fix - Fix calculating weights and delta. Add test