refactor check_dhcp method