changed reduce to apply