refactored rules API