Map gen in function