If "sel" is negative this is gonna cause some overflow problems. You should be casting size() to (int) instead.