packaged and refactored