refs #28 refactoring for speeding up