latest refactored work from tom