Used Array.map and Array.join to simplify substitute code