Fixed a sign and did a little optimization.