add patterns and fix error code