Added check for valid port list.