fix potential out of bound