Replace str join clause with reduce function