Modify scandirSync function