cleaned up mapping code