Add error rule function