Fixed null pointer in tag detection