Added error checking to BMI class and fixed loop