Completed the implementation with a testing feature for variable look-ahead check