Correcting variable declaration to int

The original code has a bug, so I corrected it.