Passed info through the function to get rid of the global variable