refactored big time