Add typecast to prevent overflow of arithmatic results