The condition with 1e9 but the math operations with 1e6 look bogus to me.