rewriting the inject method