avoid floating point arthmetic error problem