Fix JavaScript error resulting from call to .map