I think it would be better to use jQuery's `.each` here. Also make sure the lines in the given block are properly indented.