Fixed wrong generation of rules