wrote method for my_inject