refactoring spec and rules