use javascript map instead of jQuery each