Cast to int in correct place