fixed logic bug on valid_files function (in instead of not in :P)