added check to make sure files are loaded before scanning