simplified. Changed to popopen and single tag checks instead of array checks.