use double everywhere for accurate computations