Added another variable and more code to fix the issues that I was having