change tabulates to map clean up some other code