added bounds so counter cannot traverse past grid boundaries