add counter and stack implementations