some refactoring and pended failing midpoint test