optimize performce by fs
add memory overflow protection