added terminal each function for side-effects