Fixing issue with map generating funciton