refactoring and new rules implemented