used yields to replace custom function.