fix build failure and exception on the first time run.