fixed calculation with casting