refactor and rules