refactoring to move all extraction code to a class for move to GUI