replaced id with code.
replaced $.each() with Array.forEach() for better performance.