new implementation by using closure and apply