Change `unsigned int' to `int' to handle -1 value