implemented traversal & count