fix numerical problems