Fixed issue of passing variables to function (Hopefully)