Fixed error that tried to access undefined variable