move netmask to IPNetwork and refactoring code