Fixed the issues in script flow