fixed some rules, should be more robust