Fixed bounds check on toggle output function