fix some problems with overflow
fix some problems with overflow