replace list with map for NFA