Map function implemented with scoreboard. Likely has memory leaks. Needs to be refactored later on.