fixed potential overrun bug