Beginning of Map function