refactoring and check ip