Rules subroutine ready for testing