Add support for multiple IPs and restructure/rework the code