refactoring + fixed range IPs bug