updated to make filename pattern matching more flexible