Add type casting. Maths was doing some strange stuff