Adding error handling and completing add_ip