fix compile error and change lenth from int to unsigned int