cleaning up global variables and adding more comments