fixed possible error due to int flength