Fixed critical runtime error