replacing script to extract tagged entities