Solved issue of counter going below 0, giving a seg fault