js logic remake; add terms counter