move rule pattern definition into a separate class