fixed bin data overlap on margins and made the maximum margin value inclusive