updated code to more efficiently use echo commands