rewritten with mapcar instead of dolist

almost non tested, but result fairly similar