Its a Global variable. I just did not want to make it passing to all the functions.

Design can always be improved as I have just mad the algo to work.