fixed overflow bugs