Updated casting to int to Integer to avoid casting errors