moved while loop to nested function. still unable to access parameter in map file