added results logging, refactored