changed global mat list to map for better performance.