use map instead of each in check_dhcp method