Replace int cast by long cast