Fixing a bug that causes the code to crash when it is run at the pit.
(cherry picked from commit 3144b1b4)