Marginally optimised this by using less variables and only calculating discriminant once