Improved Map function to accept different arguments