some changes to ensure correct computations