Added logic to catch span and div tags