Moved scripts to bottom and switched to using jQuery.each (instead of for-loop)