corrected map. cleaned up code