Replace function "index" with "elem"