add sending IP, and refactoring