fix some bugs which may lead program crack
alnpe with sw seems to work well