fix recursion and filename priority