fix rounding error, some code formatting