add nullcheck and get value as int