fix theoretical integer overflow issues