added some map code (not tested)