reformat cod indent, fix missing checking array index