fixed potential out of bounds exception