First try of generic map function