Fixed a bug in backtracking

Had to ensure that backtracking did not go beyond the start of the
ArrayList