replace usage of map() with a for loop @coryvirok