Modified method to not destroy original array