little change to protect memery out of range