add bound checking for value