Fixed bug in mapping function.