delete unnecessary elements