my version of inject method