Replaced 3 for in loops with $.each loops in emne()