Refactor: Takes out unnecessary backtracking with '-1's.