modify rules calculation, add testing