Fixed bug where I was using total count instead of magin count.