Integer casting bug