fixing and clarifying legend calculations