got the K=3 case working correctly