Switch to using let statement to only call function once