Accidently had local declaration for the int which caused a null.