Speed improvement creating maps in js