added a cast to suppress a warning for comparison between signed and unsigned.