added address check and hostname resolve section

method split and some refactoring.