Every time your pressSegBtn function is called it's adding your 'refresh' event listener again, which is why you see it logging '3' more and more often. You only have to call .on once to register...