fix problem when no folder given
fix broken file path checking and add some debug