fixed for loop err, added map func