Refactoring code for better organization when creating new rule