added some more check in locations to this script