Updated my fix to avoid the stack variable being nil